from odoo import api, models, fields


class QualityCheck(models.Model):
    _inherit = 'quality.check'

    s_from_wms = fields.Boolean(default=False, string='wms接口自动创建')

    def do_pass(self):
        # wms接收的，质检后自动入库
        res = super().do_pass()
        self = self.sudo()
        if self.s_from_wms and all([c.quality_state=='pass' for c in self.picking_id.check_ids]):
            self.picking_id.button_validate()
        return res
